package com.blog1.common.advice;


import com.blog1.common.exception.blogException;
import com.blog1.enums.ResultCodeEnum;
import com.blog1.pojo.response.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
@Slf4j
@ResponseBody
public class exceptionAdvice{

    @ExceptionHandler
    public Result handleException(Exception e){
        log.error("发生异常：e{}",e.getMessage());
        return Result.error(ResultCodeEnum.ERROR.getMsg());
    }

    @ExceptionHandler
    public Result handleException(blogException e){
        log.error("发生异常：e{}",e.getMessage());
        return Result.error(ResultCodeEnum.ERROR.getMsg());
    }


}
